﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using HGZP.BLL;

namespace BZXT
{

    public partial class Menu : System.Web.UI.Page
    {
        public string stype = "";
        public string SiteList = string.Empty;
        public string IsSuper = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserId"] == null)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>top.location.href='../login.aspx';</script>");
                return;
            }
            if (!IsPostBack)
            {
                stype = Request.QueryString["type"];
            }
            string type = Request.QueryString["Type"];
            if (type == null)
            {
                Response.Redirect("index.aspx");
            }
            // shortcut_id.InnerHtml = ShortcutList(rd.ShortcutList(UserNum, 1));
            string getChStr = Request.QueryString["CH"];
            if (getChStr != string.Empty && getChStr != null)
            {

            }
            else
            {
                menuNavi_id.InnerHtml = menuNavilist(type);
            }
        }

        protected string menuNavilist(string type)
        {
            string liststr = "\r<div>\r";
            BaseUserBLL baseuser = new BaseUserBLL();
            System.Data.DataTable dtMenu = baseuser.GetUserFunction(Session["UserId"].ToString());
            CInfoMenuBLL infoMenu = new CInfoMenuBLL();
            if (type == "0")
                type = dtMenu.Select(string.Format("{0}='{1}'", infoMenu.sParentGuid, "0"))[0][infoMenu.sGuid].ToString();
            System.Data.DataRow[] drMenuList = dtMenu.Select(string.Format("{0}='{1}'", infoMenu.sParentGuid, type));
            if (drMenuList != null && drMenuList.Length > 0)
            {
                foreach (System.Data.DataRow drMenu in drMenuList)
                {
                    liststr += checkPr("B001", drMenu[infoMenu.sFeaturesURL].ToString(), "sys_main", drMenu[infoMenu.sCaption].ToString());
                }
            }
            liststr += "</div>";
            return liststr;
        }

        /// <summary>
        /// 权限判断
        /// </summary>
        /// <param name="code">权限代码</param>
        /// <returns></returns>
        public string checkPr(string code, string Href, string Target, string Name)
        {

            string str = "<li style=\"list-style:none;padding-left:5px;\"><img src='sysImages/default/admin/menu_dot_21.gif' alt='' border='0'><a class='menulist' href='" + Href + "' target='" + Target + "'>" + Name + "</a></li>\r";

            return str;
        }
    }
}
